package com.example.jobsearch.controller;

import com.example.jobsearch.model.CompanyInfo;
import com.example.jobsearch.service.JobSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class JobSearchController {
    @Autowired
    private JobSearchService jobSearchService;

    @GetMapping("/jobs/search")
    public List<CompanyInfo> searchJobs(@RequestParam String job_name, @RequestParam String fl) {
        return jobSearchService.searchJobs(job_name, fl);
    }

    // 修改为通过jobName获取职位详情的方法
    @GetMapping("/jobs/{jobName}")
    public CompanyInfo getJobByName(@PathVariable String jobName) {
        return jobSearchService.getJobByName(jobName);
    }
}